<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.transcargo.data.CountriesData" %>
<%@ page import="com.transcargo.geo.Country" %>
<%@ page import="com.transcargo.geo.Region" %>
<%@ page import="com.transcargo.geo.City" %>
<%@ page import="java.util.Date" %>
<%@include file="header.jsf"%>
<%@include file="session.jsf"%>
<%@include file="resolve_country.jsf"%>
<%
	Date date = new Date();
	Country[] countries = CountriesData.getCountries(dbase);

%>
<html>
  	<head><title>TransCargo</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link type="text/css" href="transcargo.css" rel="stylesheet"/>

  </head>
  <body>
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr><td colspan="2">
			<%@include file="page_header.jsf"%>
        </td></tr>
        <tr><td width="80%" align="center">
            <table width="100%" cellpadding="0" cellspacing="0">
	            <tr><td align="center"><h1>ТрансКарго</h1></td></tr>
	            <tr><td align="center"><center>Поиск грузов по странам на текущую дату</center><br><br>
				<table border="0">
				<tr><th>Страна</th><th>Загрузка</th><th>Выгрузка</th></tr> 
		<%
			for (int i = 0; i < countries.length; i++) {
				Country country = countries[i];
				list = dbase.execute("SELECT count(id) FROM posted_cargo WHERE visible=1 AND ((date_load<=CURRENT_DATE AND date_unload>=CURRENT_DATE) OR permanent=1) AND country_id_from="+country.getId());
				iter = list.iterator();
				String[] res = iter.next();
				int cargo_from = Integer.parseInt(res[0]);
				list = dbase.execute("SELECT count(id) FROM posted_cargo WHERE visible=1 AND ((date_load<=CURRENT_DATE AND date_unload>=CURRENT_DATE) OR permanent=1) AND country_id_to="+country.getId());
				iter = list.iterator();
				res = iter.next();
				int cargo_to = Integer.parseInt(res[0]);
				%><tr><td><a href="country_cargo.jsp?cid=<%=country.getId()%>"><%=country.getName() %></a></td><td align="center"><a href="search_cargo.jsp?cid_from=<%=country.getId()%>"><%=cargo_from %></a></td><td align="center"><a href="search_cargo.jsp?cid_to=<%=country.getId()%>"><%=cargo_to %></a></td></tr>
<%
			}
		
		%></table>
        </td><td valign="top"><%@include file="login.jsf"%><br><%@include file="quicksearch.jsf"%></td></tr>
    </table>
  </body>
</html>
